package com.have.blog.web.service.impl;

import com.github.pagehelper.PageHelper;
import com.have.blog.base.enums.BlogStatus;
import com.have.blog.model.mapper.TagMapper;
import com.have.blog.model.models.Tag;
import com.have.blog.model.models.TagExample;
import com.have.blog.web.service.TagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@SuppressWarnings("all")
public class TagServiceImpl implements TagService {
    @Autowired
    private TagMapper tagMapper;

    @Override
    public List<Tag> getHotTag(Integer hotTagCount) {
        PageHelper.startPage(1, hotTagCount);
        TagExample example = new TagExample();
        example.createCriteria()
                .andStatusEqualTo(BlogStatus.ENABLE.getStatus());
        example.setOrderByClause("sort,click_count desc");
        List<Tag> tagList = tagMapper.selectByExample(example);
        return tagList;
    }
}
